package koction.model.productComment;

public class PagingBean {
	private int nowPage=1;
	private int numberOfContentsPerPage=5;
	private int numberOfPageGroup=4;
	private int totalContents;
	
	public PagingBean(int nowPage, int totalContents) {
		super();
		this.nowPage = nowPage;
		this.totalContents = totalContents;
	}

	public int getNowPage() {
		return nowPage;
	}
	
	public int getTotalPage(){
		int totalPage=0;
		int num=totalContents%numberOfContentsPerPage;
		if(num==0){
			totalPage=totalContents/numberOfContentsPerPage;
		}else{
			totalPage=totalContents/numberOfContentsPerPage+1;
		}
		return totalPage;
	}
	
	public int getTotalPageGroup(){
		int totalPageGroup=0;
		int totalPage=getTotalPage();
		int num= totalPage%numberOfPageGroup;
		if(num==0){
			totalPageGroup=totalPage/numberOfPageGroup;
		}else{
			totalPageGroup=totalPage/numberOfPageGroup+1;
		}
		return totalPageGroup;
	}
	
	public int getNowPageGroup(){
		int nowPageGroup=0;
		int num= nowPage%numberOfPageGroup;
		if(num==0){
			nowPageGroup=nowPage/numberOfPageGroup;
		}else{
			nowPageGroup=nowPage/numberOfPageGroup+1;
		}
		return nowPageGroup;
	}
	
	public int getStartPageOfPageGroup(){
		return (getNowPageGroup()-1)*numberOfPageGroup+1;		
	}
	
	public int getEndPageOfPageGroup(){
		int endPage=0;
		if(getNowPageGroup()==getTotalPageGroup()){
			endPage=getTotalPage();
		}else if(totalContents==0){
			endPage=0;
		}else{
			endPage=getNowPageGroup()*numberOfPageGroup;
		}
		return endPage;
	}
	
	public boolean isPreviousPageGroup(){
		boolean result=false;
		if(getNowPageGroup()>1)
			result=true;
		return result;
	}
	
	public boolean isNextPageGroup(){
		boolean result=false;
		if(getNowPageGroup()<getTotalPageGroup())
			result=true;
		return result;
	}
	
	
	
}
